package me.zk.practice1.s;

/**
 * @author zhangkai
 * @date 2023/7/13 13:20
 */
public class LS_Offer_21 {
    public int[] exchange(int[] nums) {
        int i1 = 0;
        int i2 = nums.length-1;
        while (i1 < i2) {
          while (i1<i2 && nums[i1] % 2 ==1) {
              i1++;
          }
            while (i1<i2 && nums[i1] % 2 ==0) {
                i2--;
            }
            swap(nums,i1,i2);
        }
        return nums;
    }
    public void swap(int[] nums, int a,int b) {
        int temp = nums[a];
        nums[a] = nums[b];
        nums[b] = temp;
    }

    public static void main(String[] args) {
        new LS_Offer_21().exchange(new int[]{1,3,3,3});
    }
}
